package core.hxl;

import core.hxl.po.Users;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import java.io.Serializable;

@Slf4j
@Component
public class CommandLineRunnerImpl implements CommandLineRunner {

    @Autowired
    private RedisTemplate<String,Serializable> redisTemplate;

    @Override
    public void run(String... strings) throws Exception {
        log.info("put object to redis");
        Users users = Users.builder().username("huangxiaoli").password("123456").build();
        redisTemplate.opsForValue().set("user",users);
        log.info("get object from redis");
        Users user=(Users)redisTemplate.opsForValue().get("user");
        System.out.println(user);
    }
}
